package com.ccys.app.controller;

import com.ccys.db.page.AppPageDto;
import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.cache.UserUtil;
import com.ccys.db.dto.app.callVideoScreen.GetListLaboratoryDto;
import com.ccys.db.dto.app.callVideoScreen.GetListLaboratoryForChildDto;
import com.ccys.db.mapper.TblLabResultMapper;
import com.ccys.db.mapper.TblSupplierMapper;
import com.ccys.db.vo.app.callVideoScreen.GetBookingCdmpDetailVo;
import com.ccys.db.vo.app.callVideoScreen.GetListLaboratoryVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author：XLY
 * @Date：2024/1/22 0022
 */

@RestController
@RequestMapping("/callVideoScreen")
@Api(tags = "Call Video screen")
public class CallVideoScreenController {


    @Resource
    private TblSupplierMapper mapper;

    @Resource
    private TblLabResultMapper labResultMapper;

    @ApiOperation("Call Video screen/1")
    @GetMapping("GetListLaboratory")
    public ResponseResultApp<GetListLaboratoryVo> getListLaboratory(GetListLaboratoryDto dto) {

        //1. Member/GetListLaboratory,查询的是tbl_lab_result,在cms中Health screening -> Laboratory Results 可以添加
        String curLoginUserId = UserUtil.getCurLoginUserId();
        AppPageDto.startPage();
        List<GetListLaboratoryVo.LaboratoryVo> listLaboratory = mapper.getListLaboratory(dto, curLoginUserId);
        PageInfo<GetListLaboratoryVo.LaboratoryVo> pageInfo = new PageInfo<>(listLaboratory);
        GetListLaboratoryVo vo = new GetListLaboratoryVo();
        vo.setTotal(pageInfo.getPages());
        vo.setLaboratories(listLaboratory);
        return ResponseResultApp.success(vo);
    }


    @ApiOperation("Call Video screen / 4")
    @GetMapping("GetBookingCdmpDetail")
    public ResponseResultApp<List<GetBookingCdmpDetailVo>> getBookingCdmpDetail(String id){
        //通过tbl_booking_cdmp_package的id查询关联的tbl_cdmp_benefit的conditions和descriptionProgramme
        List<GetBookingCdmpDetailVo> vo = mapper.getBookingCdmpDetail(id);
        return ResponseResultApp.success(vo);
    }



    @ApiOperation("Call Video screen / 5")
    @GetMapping("GetListLaboratoryForChild")
    public ResponseResultApp GetListLaboratoryForChild(GetListLaboratoryForChildDto dto){
        AppPageDto.startPage();
        List<GetListLaboratoryVo.LaboratoryVo> child = mapper.getListLaboratoryForChild(dto);
        GetListLaboratoryVo vo = new GetListLaboratoryVo();
        PageInfo<GetListLaboratoryVo.LaboratoryVo> pageInfo = new PageInfo<>(child);
        vo.setTotal(pageInfo.getPages());
        vo.setLaboratories(child);
        return ResponseResultApp.success(vo);
    }



}
